var windowName = "selectStyle";
$(function () {
    // onWindowShow(function () {
    // })
    // onWindowHide(function () {
    // })
    // console.log("index page is OK");
    var OrderList = new List();
    var Page = createVM("#Page", {
        //页面数据
        id: 0,
        page: 0,
        pics: [],
        picsAll: [],
    }, {
        //页面方法

        /**
         * 生命周期函数--监听页面加载
         */
        onLoad: function (options) {
            let id = getUrlData("id");
            this.id = id
            // getOrderInfo(this)
            getData(this)

        },
        next: function (e) {

            let id = this.id
            goto("/pic/Page/Wap/selectBack.html?id=" + id)
        },
        goback: function (e) {
            let id = this.id
            // goto("/pic/Page/Wap/selectStyle.html?id=" + id)
            history.go(-1)
        }
        ,
        showMore: function () {


            let _this = this;
            let pics = _this.pics

            let find = 0;
            _this.picsAll.map(function (data, index) {
                if (index >= _this.page * 9 && index < (_this.page + 1) * 9) {
                    find = 1;
                    pics.push(data)
                }
            })
            if (find === 1) {
                showToast('加载中...')
            } else {
                showToast('已全部加载')
            }
            let page = _this.page + 1;
            _this.setData({pics, page})
        }

    })


    Page.onLoad()

})


function getData(_this) {
    let id = _this.id
    apiGet("/po/order/create/99", {id}, function (res) {
        let pics = []
        let picsAll = res.d.pics
        res.d.pics.map(function (data, index) {
            console.log(data)
            console.log(index)
            if (index >= _this.page * 9 && index < (_this.page + 1) * 9) {

                pics.push(data)
            }
        })
        let page = 1;
        _this.setData({picsAll, pics, page})
    })
}

function getOrderInfo(_this) {
    let id = _this.data.id
    api.get("/po/order/create/99", {id}, function (res) {
        console.log(res)
        let pics = []
        res.d.pics.map(function (data) {
            pics.push(config.baseUrl + data)
        })
        _this.setData({pics})
    })
}
